# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import cgi
import sys
from google.appengine.api import users
from google.appengine.ext import webapp
import logging
from google.appengine.ext.webapp.util import run_wsgi_app

import simplejson

from osapps.common.request import *
from osapps.friendforsale.model import *
#from osapps.friendforsale.commands import *
from osapps.friendforsale import commands
#TODO:maybe use yaml here
config = {"default":{"init_cash":10000,"init_price":500,
            "fix_interval":12,"reward_interval":12,
            "fawn_interval":12,"buy_limit_perday":2,
            "fix":["fix0","fix1","fix2","fix3"],
            "reward":["reward0","reward1","reward2","reward3"],
            "fawn":["fawn0","fawn1","fawn2","fawn3"]
            }}

class fsController(AppController):
    def __init__(self):
        AppController.__init__(self)
        self.setConfig(config)
        self.setCommandModule(commands)

class MainPage(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Hello')

application = webapp.WSGIApplication([('/',MainPage),
                                      ('/req',fsController)],
                                     debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
